let app = getApp()
Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    mode:'circle',// circle 圆形 square 方形
    bottom:100,//距离顶部距离 rpx
    top:50,//距离顶部多少距离显示 px
    bgColor:'blue',//背景色
    color:'#fff',//文字图标颜色
    icon:'triangleupfill',//图标
    right:'24',//距离右侧距离 rpx
    scrollTop:0,
    spinShow: false,
    loadMoreLoad: false,
    //文件资料
    study:null,
    //视频资料
    video:null
  },

  lookfile(e) {
    console.log("进入了预览功能");
    console.log(e);
    var url = e.currentTarget.dataset.url;
    console.log(url);
    // 下载文件并保存到本地
    wx.downloadFile({
      url: url,
      success: function (res) {
        var filePath = res.tempFilePath;
        wx.openDocument({
          filePath: filePath,
          fileType: "docx",
          success: function (res) {
            console.log('打开文档成功');
          },
          fail: function (error) {
            console.log('打开文档失败', error);
          }
        });
      },
      fail: function (error) {
        console.log('下载文件失败', error);
      }
    });
  },

  look(e){
    var url =e.currentTarget.dataset;
    console.log(url);
    wx.navigateTo({
      url: '/packageG/studyVideo/studyVideo?data=' +encodeURIComponent(JSON.stringify(url)) 
    })
  },
  
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      var data = JSON.parse(decodeURIComponent(options.data));
      this.setData({
        study:data.coursewareList,
        video:data.videoList
      })
      console.log(this.data.study);
      console.log(this.data.video);
    },
})